;-*- coding: utf-8 -*-
; Fritz Kunze's keyboard customization for emacs init file.
; 2009-08
; 2008-08
; 
; 

;----

;(global-set-key (kbd "M-i -") "—")
;(global-set-key (kbd "M-i '") "’")
;(global-set-key (kbd "M-i rq") "“")
;(global-set-key (kbd "M-i lq") "”")


;;With the code below, you can select a region, then press “Alt+x replace-html-chars”, and have all “&”, “>”, “<” replaced by their encoded entity. 

(defun replace-string-pairs-region (start end mylist)
  "Replace string pairs in region."
  (save-restriction 
    (narrow-to-region start end)
    (mapc
      (lambda (arg)
        (goto-char (point-min)) 
        (while (search-forward (car arg) nil t) (replace-match (cadr arg)) )
      ) mylist
    )
  )
)

(defun replace-html-chars (start end)
  "Replace “<” by “&lt;” and other similar HTML chars that needs to be encoded."
  (interactive "r")
(replace-string-pairs-region start end '(
("&" "&amp;")
("<" "&lt;")
(">" "&gt;")
    )
  )
)

;; C-c i calls insert-date-string in elisp_util.el (conflicts with org-mode!)
;; set up the key binding in keyboard.el (and not here)
;;(global-set-key (kbd "C-c i") 'insert-date-string)

;; C-c s calls insert-signature in elisp_util.el (conflicts with org-mode!)
;; C-c 4 calls insert-signature1 in elisp_util.el (conflicts with org-mode!)
;; set up the key binding in keyboard.el (and not here)
;;(global-set-key (kbd "C-c s") 'insert-signature)
;;(global-set-key (kbd "C-c r") 'insert-signature1)